﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;

namespace Utils.Common.Compute
{
    //加密算发
   public class CodingService
    {

        //MD5
        public static string ComputeMD5Hash(string source)
        {
            byte[] bytes = Encoding.UTF8.GetBytes(source);
            return Convert.ToBase64String(new MD5CryptoServiceProvider().ComputeHash(bytes));
        }
        //SHA1
        public static string ComputeSHA1Hash(string source)
        {
            byte[] bytes = Encoding.UTF8.GetBytes(source);
            return Convert.ToBase64String(new SHA1CryptoServiceProvider().ComputeHash(bytes));
        }




        public static string EncryptCode(string source)
        {
            return ComputeSHA1Hash(ComputeMD5Hash(source));
        }
    }
}
